package biz

import (
	"errors"
	"fmt"
	"time"

	"github.com/golang-jwt/jwt/v4"
)

type UserClaims struct {
	Id       int32
	AppId    int32
	ExpireAt int64
}

func (u UserClaims) Valid() error {
	fmt.Print("valid UserClaims")
	vErr := new(jwt.ValidationError)
	if time.Unix(u.ExpireAt, 0).Before(time.Now()) {
		vErr.Inner = errors.New("token is expired")
		vErr.Errors |= jwt.ValidationErrorExpired
	}
	if vErr.Errors == 0 {
		return nil
	}
	return vErr
}
